package com.googlecode.moneyManager.web.util

/**
 * Created by sergiy.doroshenko
 * Date: 9/22/11 
 */
 import scala.collection.mutable.ListBuffer

object ImplicitClose {
  def using[A <: { def close(): Unit }, B] (param: A) (f: A => B) :B  =
    try {
      f(param)
    } finally {
      param.close()
    }


  def bmap[T](test: => Boolean)(block: => T): List[T] = {
    val ret = new ListBuffer[T]
    while (test) ret += block
    ret.toList
  }
}